package com.yqg.protection.listenern;

import cn.hutool.core.bean.BeanUtil;
import com.alibaba.excel.context.AnalysisContext;
import com.alibaba.excel.event.AnalysisEventListener;
import com.yqg.protection.controller.dto.ImportProductTechTrainDto;
import com.yqg.protection.entity.ProductTechTrain;
import com.yqg.protection.mapper.ProductTechTrainMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * projectName:xf-service1
 * author:zxf
 * time:2024/10/16 14:54
 * description:
 */
@Component
public class ProductTechTrainListener extends AnalysisEventListener<ImportProductTechTrainDto> {

    @Autowired
    private ProductTechTrainMapper productTechTrainMapper;

    @Override
    public void invoke(ImportProductTechTrainDto importProductTechTrainDto, AnalysisContext analysisContext) {
        ProductTechTrain productTechTrain = new ProductTechTrain();
        BeanUtil.copyProperties(importProductTechTrainDto, productTechTrain, true);
        productTechTrain.setIsDelete(0);
        productTechTrainMapper.insert(productTechTrain);
    }

    @Override
    public void doAfterAllAnalysed(AnalysisContext analysisContext) {

    }
}
